package com.zsy.filink.basic;

import org.apache.flink.api.java.ExecutionEnvironment;
import org.apache.flink.api.java.operators.DataSource;

/**
 * @Author: Zhou ShiYang
 * @Description: 第一个基于Flink批处理快速入门案例（读取wc.data中的数据）
 * @Date:Create：in 2021/7/28 23:28
 **/
public class BatchWCApp {

    public static void main(String[] args) throws Exception{

        // 创建上下文
        ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

        // 对接数据源数据
        DataSource<String> source = env.readTextFile("data/wc.data");

        source.flatMap(new PKFlatMapFunction())
                .filter(new PKFilterFunction())
                .map(new PKMapFunction())
                .groupBy(0)
                .sum(1).print();
        /**
         * (flink,4)
         * (pk,6)
         */

    }
}
